package com.example.blog_system_ssm.common;

import java.util.HashMap;
import java.util.Objects;

//自定义同一返回对象
public class AjaxResult {
    //业务成功时的返回方法
    public static HashMap<String,Object> success(Object data){
        HashMap<String,Object> result=new HashMap<>();
        result.put("code", 200);
        result.put("msg", "");
        result.put("data", data);
        return result;
    }
    public static HashMap<String, Object> success(String msg, Object data) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("code", 200);
        result.put("msg", msg);
        result.put("data", data);
        return result;
    }

    //业务失败时的返回方法
    public static HashMap<String,Object> fail(int code, String msg){
        HashMap<String,Object> result=new HashMap<>();
        result.put("code", code);
        result.put("msg", msg);
        result.put("data", "");
        return result;
    }
    public static HashMap<String,Object> fail(int code, String msg,Object data){
        HashMap<String,Object> result=new HashMap<>();
        result.put("code", code);
        result.put("msg", msg);
        result.put("data", data);
        return result;
    }
}
